home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Recursive function -> how do you exit one
- Date: 31 Jan 1996 16:49:44 GMT
- Organization: OpenVision
- Message-ID: <4eo6j8$pb3@spanky.pls.ov.com>
- References: <4eh1g8$aba@pulp.ucs.ualberta.ca>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article aba@pulp.ucs.ualberta.ca, jbukczyn@gpu.srv.ualberta.ca (Jacob Bukczynski) writes:
- >I'm using a recursive function to search for files. I need
- >it to quit when a user presses Esc.
- >
- >Using
- >
- >return;
- >
- >doesn't seem to work, the funtion runs again. ( I tested
- >this by putting a printf statement in front of the return -
- >it got printed over and over again. )
- >
- >Is there a special way of exiting a recursive function?
- >
- >Please reply at jbukczyn@gpu.srv.ualberta.ca
- >
- >
-
-
- The standard library calls setjmp() and longjmp() were created for just
- the purpose you describe. You use setjmp() to define where to go and
- the stack environment, and if you execute longjmp(), you can avoid all of
- the deeply nested stacking represented by a recursive function.
- See K+R 2 pg.254 Section B8.
-
- Fletcher.Glenn@ov.com
-
-
-